<?php

namespace common\logics;

use Yii;
use common\helpers\Url;

/**
 * This is the model class for table "{{%user}}".
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class UserLogic extends \common\models\BaseUser {

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'nickname',
            'mobile' => function() {
                if ($this->mobile_hash) {
                    return parent::decryptMobile();
                }
                return '';
            },
            'avatar' => function() {
                return Url::attach($this->avatar);
            },
            'gender' => function() {
                return $this->meta ? $this->meta->gender : 0;
            },
            'birthday' => function() {
                return $this->meta ? $this->meta->birthday : '';
            },
            'qq' => function() {
                return $this->meta ? $this->meta->qq : '';
            },
            'signature' => function() {
                return $this->meta ? $this->meta->signature : '';
            },
            'location' => function() {
                return $this->meta ? $this->meta->location : '';
            },
            'register_time' => 'created_at',
        ];
    }

}
